import { createRouter, createWebHistory } from 'vue-router';
import { createApp } from 'vue';
import Index from '../views/index.vue';
import BusinessList from '../views/BusinessList.vue';
import BusinessListe from '../views/BusinessListe.vue';
import bsnslst from '../views/bsnslst.vue';
import BusinessInfo from '../views/BusinessInfo.vue';
import Login from '../views/Login.vue';
import Order from '../views/Order.vue';
import UserAddress from '../views/UserAddress.vue';
import Payment from '../views/Payment.vue';
import OrderList from '../views/OrderList.vue';
import AddUserAddress from '../views/AddUserAddress.vue';
import EditUserAddress from '../views/EditUserAddress.vue';
import Register from '../views/Register.vue';
import UserMenu from '../views/UserMenu.vue';

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Index
  },
  {
    path: '/index',
    name: 'Index',
    component: Index
  },
  {
    path: '/businessListe',
    name: 'BusinessListe',
    component: BusinessListe
  },
  {
    path: '/businessList',
    name: 'BusinessList',
    component: BusinessList
  },
  {
    path: '/businessInfo',
    name: 'BusinessInfo',
    component: BusinessInfo
  },
  {
    path: '/login',
    name: 'Login',
    component: Login
  },
  {
    path: '/order',
    name: 'Order',
    component: Order
  },  {
    path: '/userAddress',
    name: 'UserAddress',
    component: UserAddress
  },
  {
    path: '/payment',
    name: 'Payment',
    component: Payment
  },
  {
    path: '/orderlist',
    name: 'OrderList',
    component: OrderList
  },
  {
    path: '/addUserAddress',
    name: 'AddUserAddress',
    component: AddUserAddress
  },
  {
    path: '/editUserAddress',
    name: 'EditUserAddress',
    component: EditUserAddress
  },
  {
    path: '/register',
    name: 'Register',
    component: Register
  },
  {
    path: '/userMenu',
    name: 'UserMenu',
    component: UserMenu
  }
];

/*解决重复路由报异常*/
/*
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push (location) {
	return
	originalPush.call(this.location).catch(err => err)
}*/


const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
});
/*
const app = createApp(Index); // 创建 Vue 应用实例，传入根组件
app.use(router); // 使用路由器
app.mount('#app'); // 挂载到 DOM*/

export default router;